package com.tbit.uqbike.object.view;

import com.tbit.uqbike.webmanager.util.ExportExcelUtils;
import org.apache.poi.ss.usermodel.CellType;

import java.text.DecimalFormat;
import java.util.List;

/**
 * @author MyWin E-mail:335918956@qq.com
 * @version 1.0
 * @createTime 2019-12-17 20:32
 */
public class OrderStatData extends ExportExcelUtils.RowData {
    public static final String PRO_TOTAL_MONEY = "totalMoney";
    public static final String PRO_TOTAL_RIDE_MONEY = "totalRideMoney";
    public static final String PRO_TOTAL_VIP_MONEY = "totalVipMoney";
    public static final String PRO_TOTAL_FINE_MONEY = "totalFineMoney";
    public static final String PRO_TOTAL_DEPOSIT_MONEY = "totalDepositMoney";
    public static final String PRO_TOTAL_RECHARGE_MONEY = "totalRechargeMoney";
    /**
     * vip会员卡金额
     */
    public static final String PRO_TOTAL_DISCOUNT_MONEY = "totalDiscountMoney";
    public static final String PRO_TOTAL_REFUND_MONEY = "totalMoneyRefund";
    public static final String PRO_TOTAL_REFUND_ORDER = "totalNumberOfRefund";
    public static final String PRO_TOTAL_RIDECARD_MONEY = "totalRideCardMoney";
    public static final String PRO_TOTAL_RIDECARD_ORDER = "totalRideCardOrder";
    public static final String PRO_TOTAL_ORDER = "totalOrder";
    public static final String PRO_TOTAL_RIDE_ORDER = "totalRideOrder";
    public static final String PRO_TOTAL_VIP_ORDER = "totalVipOrder";
    public static final String PRO_TOTAL_FINE_ORDER = "totalFineOrder";
    public static final String PRO_TOTAL_DEPOSIT_ORDER = "totalDepositOrder";
    public static final String PRO_TOTAL_RECHARGE_ORDER = "totalRechargeOrder";
    /**
     * vip会员卡数
     */
    public static final String PRO_TOTAL_DISCOUNT_ORDER = "totalDiscountOrder";
    public static ExportExcelUtils.ColInfo[] TOTAL_COLS = new ExportExcelUtils.ColInfo[]{
            new ExportExcelUtils.ColInfo("运营区", CellType.STRING, 20),
            new ExportExcelUtils.ColInfo("开始时间", CellType.STRING, 14),
            new ExportExcelUtils.ColInfo("结束时间", CellType.STRING, 14),
            new ExportExcelUtils.ColInfo("总收入", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("骑行收入", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("免押收入", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("罚款收入", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("总订单", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("骑行订单", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("免押订单", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("罚款订单", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("投放车辆数", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("每车每天订单", CellType.NUMERIC, 14),
            new ExportExcelUtils.ColInfo("每车每天收入", CellType.NUMERIC, 14),
    };

    private static DecimalFormat df2 = new DecimalFormat("######.00");
    private static DecimalFormat df0 = new DecimalFormat("######");

    public String name;
    public String start;
    public String end;

    public Long totalMoney;
    public Long totalRideMoney;
    public Long totalVipMoney;
    public Long totalFineMoney;

    public Integer totalOrder;
    public Integer totalRideOrder;
    public Integer totalVipOrder;
    public Integer totalFineOrder;

    public Long totalDepositMoney;
    public Long totalRechargeMoney;

    public Integer totalDepositOrder;
    public Integer totalRechargeOrder;

    // 投放车辆数
    public Integer totalBike;
    // 平均每车每天的订单数
    public Double orderPerCarDay;
    // 平均每车每天收入
    public Long moneyPerCarDay;

    public static OrderStatData getTotalItem(List<OrderStatData> datas) {
        OrderStatData total = new OrderStatData();
        total.name = "合计";
        total.totalMoney = 0L;
        total.totalRideMoney = 0L;
        total.totalVipMoney = 0L;
        total.totalFineMoney = 0L;
        total.totalOrder = 0;
        total.totalRideOrder = 0;
        total.totalVipOrder = 0;
        total.totalFineOrder = 0;
        total.totalBike = 0;
        for (OrderStatData item : datas) {
            if (null == item) {
                continue;
            }
            total.totalMoney += item.totalMoney;
            total.totalRideMoney += item.totalRideMoney;
            total.totalVipMoney += item.totalVipMoney;
            total.totalFineMoney += item.totalFineMoney;
            total.totalOrder += item.totalOrder;
            total.totalRideOrder += item.totalRideOrder;
            total.totalVipOrder += item.totalVipOrder;
            total.totalFineOrder += item.totalFineOrder;
            total.totalBike += item.totalBike;
        }
        return total;
    }

    public static OrderStatData getNormalItem() {
        OrderStatData total = new OrderStatData();
        total.totalMoney = 0L;
        total.totalRideMoney = 0L;
        total.totalVipMoney = 0L;
        total.totalFineMoney = 0L;
        total.totalOrder = 0;
        total.totalRideOrder = 0;
        total.totalVipOrder = 0;
        total.totalFineOrder = 0;
        return total;
    }

    @Override
    public String getString(Integer i) {
        switch (i) {
            case 0:
                return name;
            case 1:
                return start;
            case 2:
                return end;
            default:
        }
        return null;
    }

    @Override
    public Double getDouble(Integer i) {
        switch (i) {
            case 3:
                return totalMoney == null ? null : totalMoney * 1.0 / 100;
            case 4:
                return totalRideMoney == null ? null : totalRideMoney * 1.0 / 100;
            case 5:
                return totalVipMoney == null ? null : totalVipMoney * 1.0 / 100;
            case 6:
                return totalFineMoney == null ? null : totalFineMoney * 1.0 / 100;
            case 7:
                return totalOrder == null ? null : totalOrder * 1.0;
            case 8:
                return totalRideOrder == null ? null : totalRideOrder * 1.0;
            case 9:
                return totalVipOrder == null ? null : totalVipOrder * 1.0;
            case 10:
                return totalFineOrder == null ? null : totalFineOrder * 1.0;
            case 11:
                return totalBike == null ? null : totalBike * 1.0;
            case 12:
                return orderPerCarDay == null ? null : orderPerCarDay * 1.0;
            case 13:
                return moneyPerCarDay == null ? null : moneyPerCarDay * 1.0 / 100;
            default:
        }
        return null;
    }
}
